import { request, config } from 'utils'
import * as commonService from 'utils/services'

const {api: {distributor}} = config

/**
 * 获取信息
 */
export async function findByOrg (code) {
  const url = `${distributor}/findByOrg/${code}`
  return request({url: url, method: 'GET'})
}

/**
 * 设置为门店
 * @param code
 * @return {Promise<*>}
 */
export async function addWithOrg (code, params) {
  const url = `${distributor}/addWithOrg/${code}`
  return request({url: url, method: 'POST', data: params})
}

/**
 * 修改门店
 * @param id
 * @param params
 * @return {Promise<*>}
 */
export async function update (id, params) {
  const url = `${distributor}/${id}`
  return request({url: url, method: 'PUT', data: params})
}

export async function enable (id) {
  const url = `${distributor}/${id}/enable`
  return request({url: url, method: 'POST'})
}

export async function disable (id) {
  const url = `${distributor}/${id}/disable`
  return request({url: url, method: 'POST'})
}

export async function mine () {
  const url = `${distributor}/mine`
  return request({url: url, method: 'GET'})
}

export async function detail (id) {
  const url = `${distributor}/detail/${id}`
  return request({url: url, method: 'GET'})
}
export async function levelSort (parentId,childId) {
  const url = `${distributor}/${parentId}/${childId}/sortAs`
  return request({url: url, method: 'POST'})
}
